package com.tourism.order.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.tourism.order.domain.TourismOrder;
import com.tourism.order.service.ITourismOrderService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 产品订单Controller
 * 
 * @author silenceEcho
 * @date 2025-04-13
 */
@RestController
public class TourismOrderController extends BaseController
{
    @Autowired
    private ITourismOrderService tourismOrderService;

    /**
     * 查询产品订单列表
     */
    @RequiresPermissions("tourism:order:list")
    @GetMapping("/list")
    public TableDataInfo list(TourismOrder tourismOrder)
    {
        startPage();
        List<TourismOrder> list = tourismOrderService.selectTourismOrderList(tourismOrder);
        return getDataTable(list);
    }

    /**
     * 导出产品订单列表
     */
    @RequiresPermissions("tourism:order:export")
    @Log(title = "产品订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TourismOrder tourismOrder)
    {
        List<TourismOrder> list = tourismOrderService.selectTourismOrderList(tourismOrder);
        ExcelUtil<TourismOrder> util = new ExcelUtil<TourismOrder>(TourismOrder.class);
        util.exportExcel(response, list, "产品订单数据");
    }

    /**
     * 获取产品订单详细信息
     */
    @RequiresPermissions("tourism:order:query")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return success(tourismOrderService.selectTourismOrderByOrderId(orderId));
    }

    /**
     * 新增产品订单
     */
    @RequiresPermissions("tourism:order:add")
    @Log(title = "产品订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TourismOrder tourismOrder)
    {
        return toAjax(tourismOrderService.insertTourismOrder(tourismOrder));
    }

    /**
     * 修改产品订单
     */
    @RequiresPermissions("tourism:order:edit")
    @Log(title = "产品订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TourismOrder tourismOrder)
    {
        return toAjax(tourismOrderService.updateTourismOrder(tourismOrder));
    }

    /**
     * 删除产品订单
     */
    @RequiresPermissions("tourism:order:remove")
    @Log(title = "产品订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(tourismOrderService.deleteTourismOrderByOrderIds(orderIds));
    }
}
